package com.livestocksolutions;

import com.livestocksolutions.util.UpdateHistory;

/* -- Version History --
 *  1.0 : 11 July 2012 - Initial version.
 *  
 *  1.1 : 11 July 2012 - Moved String name, getName() and setName(String) from to Owner Class
 *  
 *  1.2 : 16 July 2012 - Class now implements Serializable
 *  
 *  1.3 : 16 September 2012 - Farm changed to extend Business
 *  
 *  1.4 : 24 September 2012 - Serialisation method no longer requires MedicalHistory implementing Serializable.
 */

/**
 * This class contains details for a Farm that is used as a contact
 * @author Adam Parr
 * @version 1.4
 * 
 * @.modified 24 September 2012
 */
public class Farm extends Business {
	/**
	 * A unique identification that is given to this farm
	 */
	protected String farmID;
	
	/**
	 * Constructor for creating a Farm Owner
	 */
	public Farm(){
		super();
	}
	
	/**
	 * Constructor
	 * @param id The id of the previous version of this Owner Object
	 */
	protected Farm(long id){
		super(id);
	}
	
	/**
	 * Set the ID of this Farm to the one provided
	 * @param farmID The new ID to give to this Farm
	 */
	public void setFarmID(String farmID){
		if(!this.farmID.equals(farmID)){
			this.farmID=farmID;
			update.put("FARMID", new UpdateHistory(this.farmID));
		}
	}
	
	/**
	 * Get the ID of this Farm
	 * @return Farm's identificaftion
	 */
	public String getFarmID(){
		return farmID;
	}
	
	/**
	 * Updates this Object with the updated values from the different version.
	 * @param changes Owner that represents this Object in a different version.
	 * @return <tt>true</tt> if changes is not null and changes does not equal this object, <tt>false</tt> otherwise.
	 */
	public boolean update(Farm changes){
		if(changes!=null && this!=changes){
			super.update(changes);
			
			if(updateBefore("FARMID",changes)){
				farmID=changes.update.get("FARMID").getValue();
				update.put("FARMID", new UpdateHistory(this.farmID));
			}
			return true;
		}
		return false;
	}
}
